package cn.bellychang.config;

/**
 * @author ChangLiang
 * @date 2020/9/10
 */
public class DataSourceContextHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    public static void setDB(String dbType) {
        contextHolder.set(dbType);
    }

    public static String getDB() {
        return contextHolder.get();
    }

    /**
     * 防止线程复用残留
     */
    public static void clearDB() {
        contextHolder.remove();
    }
}
